using System;
using System.Text;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using iBeauty.BusinessObjects;

namespace iBeauty.DAL
{
	public class StaffDAO
	{
		public StaffDAO()
		{
			DbProviderHelper.GetConnection();
		}
		public List<Staff> GetStaffs()
		{
			try
			{
				List<Staff> lstStaffs = new List<Staff>();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [ID],[CreateDate],[ModifiedDate],[TimeStamp],[StaffCode],[StaffName],[ShopId],[Address],[Email],[Phone],[CommissionType],[CommissionByPercent],[CommissionByMoney],[SalaryType],[BaseSalary],[Allowance1],[Allowance2],[Allowance3],[AllowanceName1],[AllowanceName2],[AllowanceName3],[NumOfDependents],[PersonalDeduction],[IsRetired],[StartTime],[Barcode],[EndTime],[BreakTime],[WorkList],[IsScheduleWorkTime],[IsCommissionService],[IsServiceCard],[AccountId],[Note] FROM [Staff]",CommandType.Text);
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					Staff oStaff = new Staff();
					oStaff.ID = Convert.ToString(oDbDataReader["ID"]);

					if(oDbDataReader["CreateDate"] != DBNull.Value)
						oStaff.CreateDate = Convert.ToDateTime(oDbDataReader["CreateDate"]);

					if(oDbDataReader["ModifiedDate"] != DBNull.Value)
						oStaff.ModifiedDate = Convert.ToDateTime(oDbDataReader["ModifiedDate"]);

					if(oDbDataReader["TimeStamp"] != DBNull.Value)
						oStaff.TimeStamp = Convert.ToDateTime(oDbDataReader["TimeStamp"]);

					if(oDbDataReader["StaffCode"] != DBNull.Value)
						oStaff.StaffCode = Convert.ToString(oDbDataReader["StaffCode"]);

					if(oDbDataReader["StaffName"] != DBNull.Value)
						oStaff.StaffName = Convert.ToString(oDbDataReader["StaffName"]);

					if(oDbDataReader["ShopId"] != DBNull.Value)
						oStaff.ShopId = Convert.ToInt32(oDbDataReader["ShopId"]);

					if(oDbDataReader["Address"] != DBNull.Value)
						oStaff.Address = Convert.ToString(oDbDataReader["Address"]);

					if(oDbDataReader["Email"] != DBNull.Value)
						oStaff.Email = Convert.ToString(oDbDataReader["Email"]);

					if(oDbDataReader["Phone"] != DBNull.Value)
						oStaff.Phone = Convert.ToString(oDbDataReader["Phone"]);

					if(oDbDataReader["CommissionType"] != DBNull.Value)
						oStaff.CommissionType = Convert.ToInt32(oDbDataReader["CommissionType"]);

					if(oDbDataReader["CommissionByPercent"] != DBNull.Value)
						oStaff.CommissionByPercent = Convert.ToSingle(oDbDataReader["CommissionByPercent"]);

					if(oDbDataReader["CommissionByMoney"] != DBNull.Value)
						oStaff.CommissionByMoney = Convert.ToSingle(oDbDataReader["CommissionByMoney"]);

					if(oDbDataReader["SalaryType"] != DBNull.Value)
						oStaff.SalaryType = Convert.ToInt32(oDbDataReader["SalaryType"]);

					if(oDbDataReader["BaseSalary"] != DBNull.Value)
						oStaff.BaseSalary = Convert.ToSingle(oDbDataReader["BaseSalary"]);

					if(oDbDataReader["Allowance1"] != DBNull.Value)
						oStaff.Allowance1 = Convert.ToSingle(oDbDataReader["Allowance1"]);

					if(oDbDataReader["Allowance2"] != DBNull.Value)
						oStaff.Allowance2 = Convert.ToSingle(oDbDataReader["Allowance2"]);

					if(oDbDataReader["Allowance3"] != DBNull.Value)
						oStaff.Allowance3 = Convert.ToSingle(oDbDataReader["Allowance3"]);

					if(oDbDataReader["AllowanceName1"] != DBNull.Value)
						oStaff.AllowanceName1 = Convert.ToString(oDbDataReader["AllowanceName1"]);

					if(oDbDataReader["AllowanceName2"] != DBNull.Value)
						oStaff.AllowanceName2 = Convert.ToString(oDbDataReader["AllowanceName2"]);

					if(oDbDataReader["AllowanceName3"] != DBNull.Value)
						oStaff.AllowanceName3 = Convert.ToString(oDbDataReader["AllowanceName3"]);

					if(oDbDataReader["NumOfDependents"] != DBNull.Value)
						oStaff.NumOfDependents = Convert.ToInt32(oDbDataReader["NumOfDependents"]);

					if(oDbDataReader["PersonalDeduction"] != DBNull.Value)
						oStaff.PersonalDeduction = Convert.ToSingle(oDbDataReader["PersonalDeduction"]);

					if(oDbDataReader["IsRetired"] != DBNull.Value)
						oStaff.IsRetired = Convert.ToString(oDbDataReader["IsRetired"]);

					if(oDbDataReader["StartTime"] != DBNull.Value)
						oStaff.StartTime = Convert.ToDateTime(oDbDataReader["StartTime"]);

					if(oDbDataReader["Barcode"] != DBNull.Value)
						oStaff.Barcode = Convert.ToString(oDbDataReader["Barcode"]);

					if(oDbDataReader["EndTime"] != DBNull.Value)
						oStaff.EndTime = Convert.ToDateTime(oDbDataReader["EndTime"]);

					if(oDbDataReader["BreakTime"] != DBNull.Value)
						oStaff.BreakTime = Convert.ToDateTime(oDbDataReader["BreakTime"]);

					if(oDbDataReader["WorkList"] != DBNull.Value)
						oStaff.WorkList = Convert.ToString(oDbDataReader["WorkList"]);

					if(oDbDataReader["IsScheduleWorkTime"] != DBNull.Value)
						oStaff.IsScheduleWorkTime = Convert.ToString(oDbDataReader["IsScheduleWorkTime"]);

					if(oDbDataReader["IsCommissionService"] != DBNull.Value)
						oStaff.IsCommissionService = Convert.ToString(oDbDataReader["IsCommissionService"]);

					if(oDbDataReader["IsServiceCard"] != DBNull.Value)
						oStaff.IsServiceCard = Convert.ToString(oDbDataReader["IsServiceCard"]);

					if(oDbDataReader["AccountId"] != DBNull.Value)
						oStaff.AccountId = Convert.ToInt32(oDbDataReader["AccountId"]);

					if(oDbDataReader["Note"] != DBNull.Value)
						oStaff.Note = Convert.ToString(oDbDataReader["Note"]);
					lstStaffs.Add(oStaff);
				}
				oDbDataReader.Close();
				return lstStaffs;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public Staff GetStaff(string ID)
		{
			try
			{
				Staff oStaff = new Staff();
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("SELECT [ID],[CreateDate],[ModifiedDate],[TimeStamp],[StaffCode],[StaffName],[ShopId],[Address],[Email],[Phone],[CommissionType],[CommissionByPercent],[CommissionByMoney],[SalaryType],[BaseSalary],[Allowance1],[Allowance2],[Allowance3],[AllowanceName1],[AllowanceName2],[AllowanceName3],[NumOfDependents],[PersonalDeduction],[IsRetired],[StartTime],[Barcode],[EndTime],[BreakTime],[WorkList],[IsScheduleWorkTime],[IsCommissionService],[IsServiceCard],[AccountId],[Note] FROM [Staff] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				DbDataReader oDbDataReader = DbProviderHelper.ExecuteReader(oDbCommand);
				while (oDbDataReader.Read())
				{
					oStaff.ID = Convert.ToString(oDbDataReader["ID"]);

					if(oDbDataReader["CreateDate"] != DBNull.Value)
						oStaff.CreateDate = Convert.ToDateTime(oDbDataReader["CreateDate"]);

					if(oDbDataReader["ModifiedDate"] != DBNull.Value)
						oStaff.ModifiedDate = Convert.ToDateTime(oDbDataReader["ModifiedDate"]);

					if(oDbDataReader["TimeStamp"] != DBNull.Value)
						oStaff.TimeStamp = Convert.ToDateTime(oDbDataReader["TimeStamp"]);

					if(oDbDataReader["StaffCode"] != DBNull.Value)
						oStaff.StaffCode = Convert.ToString(oDbDataReader["StaffCode"]);

					if(oDbDataReader["StaffName"] != DBNull.Value)
						oStaff.StaffName = Convert.ToString(oDbDataReader["StaffName"]);

					if(oDbDataReader["ShopId"] != DBNull.Value)
						oStaff.ShopId = Convert.ToInt32(oDbDataReader["ShopId"]);

					if(oDbDataReader["Address"] != DBNull.Value)
						oStaff.Address = Convert.ToString(oDbDataReader["Address"]);

					if(oDbDataReader["Email"] != DBNull.Value)
						oStaff.Email = Convert.ToString(oDbDataReader["Email"]);

					if(oDbDataReader["Phone"] != DBNull.Value)
						oStaff.Phone = Convert.ToString(oDbDataReader["Phone"]);

					if(oDbDataReader["CommissionType"] != DBNull.Value)
						oStaff.CommissionType = Convert.ToInt32(oDbDataReader["CommissionType"]);

					if(oDbDataReader["CommissionByPercent"] != DBNull.Value)
						oStaff.CommissionByPercent = Convert.ToSingle(oDbDataReader["CommissionByPercent"]);

					if(oDbDataReader["CommissionByMoney"] != DBNull.Value)
						oStaff.CommissionByMoney = Convert.ToSingle(oDbDataReader["CommissionByMoney"]);

					if(oDbDataReader["SalaryType"] != DBNull.Value)
						oStaff.SalaryType = Convert.ToInt32(oDbDataReader["SalaryType"]);

					if(oDbDataReader["BaseSalary"] != DBNull.Value)
						oStaff.BaseSalary = Convert.ToSingle(oDbDataReader["BaseSalary"]);

					if(oDbDataReader["Allowance1"] != DBNull.Value)
						oStaff.Allowance1 = Convert.ToSingle(oDbDataReader["Allowance1"]);

					if(oDbDataReader["Allowance2"] != DBNull.Value)
						oStaff.Allowance2 = Convert.ToSingle(oDbDataReader["Allowance2"]);

					if(oDbDataReader["Allowance3"] != DBNull.Value)
						oStaff.Allowance3 = Convert.ToSingle(oDbDataReader["Allowance3"]);

					if(oDbDataReader["AllowanceName1"] != DBNull.Value)
						oStaff.AllowanceName1 = Convert.ToString(oDbDataReader["AllowanceName1"]);

					if(oDbDataReader["AllowanceName2"] != DBNull.Value)
						oStaff.AllowanceName2 = Convert.ToString(oDbDataReader["AllowanceName2"]);

					if(oDbDataReader["AllowanceName3"] != DBNull.Value)
						oStaff.AllowanceName3 = Convert.ToString(oDbDataReader["AllowanceName3"]);

					if(oDbDataReader["NumOfDependents"] != DBNull.Value)
						oStaff.NumOfDependents = Convert.ToInt32(oDbDataReader["NumOfDependents"]);

					if(oDbDataReader["PersonalDeduction"] != DBNull.Value)
						oStaff.PersonalDeduction = Convert.ToSingle(oDbDataReader["PersonalDeduction"]);

					if(oDbDataReader["IsRetired"] != DBNull.Value)
						oStaff.IsRetired = Convert.ToString(oDbDataReader["IsRetired"]);

					if(oDbDataReader["StartTime"] != DBNull.Value)
						oStaff.StartTime = Convert.ToDateTime(oDbDataReader["StartTime"]);

					if(oDbDataReader["Barcode"] != DBNull.Value)
						oStaff.Barcode = Convert.ToString(oDbDataReader["Barcode"]);

					if(oDbDataReader["EndTime"] != DBNull.Value)
						oStaff.EndTime = Convert.ToDateTime(oDbDataReader["EndTime"]);

					if(oDbDataReader["BreakTime"] != DBNull.Value)
						oStaff.BreakTime = Convert.ToDateTime(oDbDataReader["BreakTime"]);

					if(oDbDataReader["WorkList"] != DBNull.Value)
						oStaff.WorkList = Convert.ToString(oDbDataReader["WorkList"]);

					if(oDbDataReader["IsScheduleWorkTime"] != DBNull.Value)
						oStaff.IsScheduleWorkTime = Convert.ToString(oDbDataReader["IsScheduleWorkTime"]);

					if(oDbDataReader["IsCommissionService"] != DBNull.Value)
						oStaff.IsCommissionService = Convert.ToString(oDbDataReader["IsCommissionService"]);

					if(oDbDataReader["IsServiceCard"] != DBNull.Value)
						oStaff.IsServiceCard = Convert.ToString(oDbDataReader["IsServiceCard"]);

					if(oDbDataReader["AccountId"] != DBNull.Value)
						oStaff.AccountId = Convert.ToInt32(oDbDataReader["AccountId"]);

					if(oDbDataReader["Note"] != DBNull.Value)
						oStaff.Note = Convert.ToString(oDbDataReader["Note"]);
				}
				oDbDataReader.Close();
				return oStaff;
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddStaff(string ID,DateTime?CreateDate,DateTime?ModifiedDate,DateTime?TimeStamp,string StaffCode,string StaffName,int?ShopId,string Address,string Email,string Phone,int?CommissionType,Single?CommissionByPercent,Single?CommissionByMoney,int?SalaryType,Single?BaseSalary,Single?Allowance1,Single?Allowance2,Single?Allowance3,string AllowanceName1,string AllowanceName2,string AllowanceName3,int?NumOfDependents,Single?PersonalDeduction,string IsRetired,DateTime?StartTime,string Barcode,DateTime?EndTime,DateTime?BreakTime,string WorkList,string IsScheduleWorkTime,string IsCommissionService,string IsServiceCard,int?AccountId,string Note)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [Staff]([CreateDate],[ModifiedDate],[TimeStamp],[StaffCode],[StaffName],[ShopId],[Address],[Email],[Phone],[CommissionType],[CommissionByPercent],[CommissionByMoney],[SalaryType],[BaseSalary],[Allowance1],[Allowance2],[Allowance3],[AllowanceName1],[AllowanceName2],[AllowanceName3],[NumOfDependents],[PersonalDeduction],[IsRetired],[StartTime],[Barcode],[EndTime],[BreakTime],[WorkList],[IsScheduleWorkTime],[IsCommissionService],[IsServiceCard],[AccountId],[Note])VALUES(@CreateDate,@ModifiedDate,@TimeStamp,@StaffCode,@StaffName,@ShopId,@Address,@Email,@Phone,@CommissionType,@CommissionByPercent,@CommissionByMoney,@SalaryType,@BaseSalary,@Allowance1,@Allowance2,@Allowance3,@AllowanceName1,@AllowanceName2,@AllowanceName3,@NumOfDependents,@PersonalDeduction,@IsRetired,@StartTime,@Barcode,@EndTime,@BreakTime,@WorkList,@IsScheduleWorkTime,@IsCommissionService,@IsServiceCard,@AccountId,@Note)",CommandType.Text);
				if (CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (StaffCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,StaffCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,DBNull.Value));
				if (StaffName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,StaffName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,DBNull.Value));
				if (ShopId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,ShopId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,DBNull.Value));
				if (Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (CommissionType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,CommissionType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,DBNull.Value));
				if (CommissionByPercent.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,CommissionByPercent));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,DBNull.Value));
				if (CommissionByMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,CommissionByMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,DBNull.Value));
				if (SalaryType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,SalaryType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,DBNull.Value));
				if (BaseSalary.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,BaseSalary));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,DBNull.Value));
				if (Allowance1.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,Allowance1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,DBNull.Value));
				if (Allowance2.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,Allowance2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,DBNull.Value));
				if (Allowance3.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,Allowance3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,DBNull.Value));
				if (AllowanceName1!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,AllowanceName1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,DBNull.Value));
				if (AllowanceName2!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,AllowanceName2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,DBNull.Value));
				if (AllowanceName3!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,AllowanceName3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,DBNull.Value));
				if (NumOfDependents.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,NumOfDependents));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,DBNull.Value));
				if (PersonalDeduction.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,PersonalDeduction));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,DBNull.Value));
				if (IsRetired!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,IsRetired));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,DBNull.Value));
				if (StartTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,StartTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,DBNull.Value));
				if (Barcode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,Barcode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,DBNull.Value));
				if (EndTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,EndTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,DBNull.Value));
				if (BreakTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,BreakTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,DBNull.Value));
				if (WorkList!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,WorkList));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,DBNull.Value));
				if (IsScheduleWorkTime!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,IsScheduleWorkTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,DBNull.Value));
				if (IsCommissionService!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,IsCommissionService));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,DBNull.Value));
				if (IsServiceCard!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,IsServiceCard));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,DBNull.Value));
				if (AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int AddStaff(Staff oStaff)
		{
			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("INSERT INTO [Staff]([CreateDate],[ModifiedDate],[TimeStamp],[StaffCode],[StaffName],[ShopId],[Address],[Email],[Phone],[CommissionType],[CommissionByPercent],[CommissionByMoney],[SalaryType],[BaseSalary],[Allowance1],[Allowance2],[Allowance3],[AllowanceName1],[AllowanceName2],[AllowanceName3],[NumOfDependents],[PersonalDeduction],[IsRetired],[StartTime],[Barcode],[EndTime],[BreakTime],[WorkList],[IsScheduleWorkTime],[IsCommissionService],[IsServiceCard],[AccountId],[Note])VALUES(@CreateDate,@ModifiedDate,@TimeStamp,@StaffCode,@StaffName,@ShopId,@Address,@Email,@Phone,@CommissionType,@CommissionByPercent,@CommissionByMoney,@SalaryType,@BaseSalary,@Allowance1,@Allowance2,@Allowance3,@AllowanceName1,@AllowanceName2,@AllowanceName3,@NumOfDependents,@PersonalDeduction,@IsRetired,@StartTime,@Barcode,@EndTime,@BreakTime,@WorkList,@IsScheduleWorkTime,@IsCommissionService,@IsServiceCard,@AccountId,@Note)",CommandType.Text);
				if (oStaff.CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,oStaff.CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (oStaff.ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,oStaff.ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (oStaff.TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,oStaff.TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (oStaff.StaffCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,oStaff.StaffCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,DBNull.Value));
				if (oStaff.StaffName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,oStaff.StaffName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,DBNull.Value));
				if (oStaff.ShopId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,oStaff.ShopId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,DBNull.Value));
				if (oStaff.Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,oStaff.Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (oStaff.Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,oStaff.Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (oStaff.Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,oStaff.Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (oStaff.CommissionType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,oStaff.CommissionType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,DBNull.Value));
				if (oStaff.CommissionByPercent.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,oStaff.CommissionByPercent));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,DBNull.Value));
				if (oStaff.CommissionByMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,oStaff.CommissionByMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,DBNull.Value));
				if (oStaff.SalaryType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,oStaff.SalaryType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,DBNull.Value));
				if (oStaff.BaseSalary.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,oStaff.BaseSalary));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,DBNull.Value));
				if (oStaff.Allowance1.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,oStaff.Allowance1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,DBNull.Value));
				if (oStaff.Allowance2.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,oStaff.Allowance2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,DBNull.Value));
				if (oStaff.Allowance3.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,oStaff.Allowance3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,DBNull.Value));
				if (oStaff.AllowanceName1!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,oStaff.AllowanceName1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,DBNull.Value));
				if (oStaff.AllowanceName2!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,oStaff.AllowanceName2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,DBNull.Value));
				if (oStaff.AllowanceName3!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,oStaff.AllowanceName3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,DBNull.Value));
				if (oStaff.NumOfDependents.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,oStaff.NumOfDependents));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,DBNull.Value));
				if (oStaff.PersonalDeduction.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,oStaff.PersonalDeduction));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,DBNull.Value));
				if (oStaff.IsRetired!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,oStaff.IsRetired));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,DBNull.Value));
				if (oStaff.StartTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,oStaff.StartTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,DBNull.Value));
				if (oStaff.Barcode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,oStaff.Barcode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,DBNull.Value));
				if (oStaff.EndTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,oStaff.EndTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,DBNull.Value));
				if (oStaff.BreakTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,oStaff.BreakTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,DBNull.Value));
				if (oStaff.WorkList!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,oStaff.WorkList));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,DBNull.Value));
				if (oStaff.IsScheduleWorkTime!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,oStaff.IsScheduleWorkTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,DBNull.Value));
				if (oStaff.IsCommissionService!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,oStaff.IsCommissionService));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,DBNull.Value));
				if (oStaff.IsServiceCard!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,oStaff.IsServiceCard));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,DBNull.Value));
				if (oStaff.AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,oStaff.AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (oStaff.Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,oStaff.Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));

				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateStaff(string ID,DateTime?CreateDate,DateTime?ModifiedDate,DateTime?TimeStamp,string StaffCode,string StaffName,int?ShopId,string Address,string Email,string Phone,int?CommissionType,Single?CommissionByPercent,Single?CommissionByMoney,int?SalaryType,Single?BaseSalary,Single?Allowance1,Single?Allowance2,Single?Allowance3,string AllowanceName1,string AllowanceName2,string AllowanceName3,int?NumOfDependents,Single?PersonalDeduction,string IsRetired,DateTime?StartTime,string Barcode,DateTime?EndTime,DateTime?BreakTime,string WorkList,string IsScheduleWorkTime,string IsCommissionService,string IsServiceCard,int?AccountId,string Note)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [Staff] SET [CreateDate]=@CreateDate,[ModifiedDate]=@ModifiedDate,[TimeStamp]=@TimeStamp,[StaffCode]=@StaffCode,[StaffName]=@StaffName,[ShopId]=@ShopId,[Address]=@Address,[Email]=@Email,[Phone]=@Phone,[CommissionType]=@CommissionType,[CommissionByPercent]=@CommissionByPercent,[CommissionByMoney]=@CommissionByMoney,[SalaryType]=@SalaryType,[BaseSalary]=@BaseSalary,[Allowance1]=@Allowance1,[Allowance2]=@Allowance2,[Allowance3]=@Allowance3,[AllowanceName1]=@AllowanceName1,[AllowanceName2]=@AllowanceName2,[AllowanceName3]=@AllowanceName3,[NumOfDependents]=@NumOfDependents,[PersonalDeduction]=@PersonalDeduction,[IsRetired]=@IsRetired,[StartTime]=@StartTime,[Barcode]=@Barcode,[EndTime]=@EndTime,[BreakTime]=@BreakTime,[WorkList]=@WorkList,[IsScheduleWorkTime]=@IsScheduleWorkTime,[IsCommissionService]=@IsCommissionService,[IsServiceCard]=@IsServiceCard,[AccountId]=@AccountId,[Note]=@Note WHERE [ID]=@ID",CommandType.Text);
				if (CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (StaffCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,StaffCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,DBNull.Value));
				if (StaffName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,StaffName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,DBNull.Value));
				if (ShopId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,ShopId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,DBNull.Value));
				if (Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (CommissionType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,CommissionType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,DBNull.Value));
				if (CommissionByPercent.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,CommissionByPercent));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,DBNull.Value));
				if (CommissionByMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,CommissionByMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,DBNull.Value));
				if (SalaryType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,SalaryType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,DBNull.Value));
				if (BaseSalary.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,BaseSalary));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,DBNull.Value));
				if (Allowance1.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,Allowance1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,DBNull.Value));
				if (Allowance2.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,Allowance2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,DBNull.Value));
				if (Allowance3.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,Allowance3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,DBNull.Value));
				if (AllowanceName1!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,AllowanceName1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,DBNull.Value));
				if (AllowanceName2!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,AllowanceName2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,DBNull.Value));
				if (AllowanceName3!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,AllowanceName3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,DBNull.Value));
				if (NumOfDependents.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,NumOfDependents));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,DBNull.Value));
				if (PersonalDeduction.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,PersonalDeduction));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,DBNull.Value));
				if (IsRetired!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,IsRetired));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,DBNull.Value));
				if (StartTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,StartTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,DBNull.Value));
				if (Barcode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,Barcode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,DBNull.Value));
				if (EndTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,EndTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,DBNull.Value));
				if (BreakTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,BreakTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,DBNull.Value));
				if (WorkList!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,WorkList));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,DBNull.Value));
				if (IsScheduleWorkTime!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,IsScheduleWorkTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,DBNull.Value));
				if (IsCommissionService!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,IsCommissionService));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,DBNull.Value));
				if (IsServiceCard!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,IsServiceCard));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,DBNull.Value));
				if (AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int UpdateStaff(Staff oStaff)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("UPDATE [Staff] SET [CreateDate]=@CreateDate,[ModifiedDate]=@ModifiedDate,[TimeStamp]=@TimeStamp,[StaffCode]=@StaffCode,[StaffName]=@StaffName,[ShopId]=@ShopId,[Address]=@Address,[Email]=@Email,[Phone]=@Phone,[CommissionType]=@CommissionType,[CommissionByPercent]=@CommissionByPercent,[CommissionByMoney]=@CommissionByMoney,[SalaryType]=@SalaryType,[BaseSalary]=@BaseSalary,[Allowance1]=@Allowance1,[Allowance2]=@Allowance2,[Allowance3]=@Allowance3,[AllowanceName1]=@AllowanceName1,[AllowanceName2]=@AllowanceName2,[AllowanceName3]=@AllowanceName3,[NumOfDependents]=@NumOfDependents,[PersonalDeduction]=@PersonalDeduction,[IsRetired]=@IsRetired,[StartTime]=@StartTime,[Barcode]=@Barcode,[EndTime]=@EndTime,[BreakTime]=@BreakTime,[WorkList]=@WorkList,[IsScheduleWorkTime]=@IsScheduleWorkTime,[IsCommissionService]=@IsCommissionService,[IsServiceCard]=@IsServiceCard,[AccountId]=@AccountId,[Note]=@Note WHERE [ID]=@ID",CommandType.Text);
				if (oStaff.CreateDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,oStaff.CreateDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CreateDate",DbType.DateTime,DBNull.Value));
				if (oStaff.ModifiedDate.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,oStaff.ModifiedDate));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ModifiedDate",DbType.DateTime,DBNull.Value));
				if (oStaff.TimeStamp.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,oStaff.TimeStamp));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@TimeStamp",DbType.DateTime,DBNull.Value));
				if (oStaff.StaffCode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,oStaff.StaffCode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffCode",DbType.String,DBNull.Value));
				if (oStaff.StaffName!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,oStaff.StaffName));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StaffName",DbType.String,DBNull.Value));
				if (oStaff.ShopId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,oStaff.ShopId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ShopId",DbType.Int32,DBNull.Value));
				if (oStaff.Address!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,oStaff.Address));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Address",DbType.String,DBNull.Value));
				if (oStaff.Email!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,oStaff.Email));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Email",DbType.String,DBNull.Value));
				if (oStaff.Phone!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,oStaff.Phone));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Phone",DbType.String,DBNull.Value));
				if (oStaff.CommissionType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,oStaff.CommissionType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionType",DbType.Int32,DBNull.Value));
				if (oStaff.CommissionByPercent.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,oStaff.CommissionByPercent));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByPercent",DbType.Single,DBNull.Value));
				if (oStaff.CommissionByMoney.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,oStaff.CommissionByMoney));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@CommissionByMoney",DbType.Single,DBNull.Value));
				if (oStaff.SalaryType.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,oStaff.SalaryType));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@SalaryType",DbType.Int32,DBNull.Value));
				if (oStaff.BaseSalary.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,oStaff.BaseSalary));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BaseSalary",DbType.Single,DBNull.Value));
				if (oStaff.Allowance1.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,oStaff.Allowance1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance1",DbType.Single,DBNull.Value));
				if (oStaff.Allowance2.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,oStaff.Allowance2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance2",DbType.Single,DBNull.Value));
				if (oStaff.Allowance3.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,oStaff.Allowance3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Allowance3",DbType.Single,DBNull.Value));
				if (oStaff.AllowanceName1!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,oStaff.AllowanceName1));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName1",DbType.String,DBNull.Value));
				if (oStaff.AllowanceName2!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,oStaff.AllowanceName2));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName2",DbType.String,DBNull.Value));
				if (oStaff.AllowanceName3!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,oStaff.AllowanceName3));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AllowanceName3",DbType.String,DBNull.Value));
				if (oStaff.NumOfDependents.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,oStaff.NumOfDependents));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@NumOfDependents",DbType.Int32,DBNull.Value));
				if (oStaff.PersonalDeduction.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,oStaff.PersonalDeduction));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@PersonalDeduction",DbType.Single,DBNull.Value));
				if (oStaff.IsRetired!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,oStaff.IsRetired));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsRetired",DbType.String,DBNull.Value));
				if (oStaff.StartTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,oStaff.StartTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@StartTime",DbType.DateTime,DBNull.Value));
				if (oStaff.Barcode!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,oStaff.Barcode));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Barcode",DbType.String,DBNull.Value));
				if (oStaff.EndTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,oStaff.EndTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@EndTime",DbType.DateTime,DBNull.Value));
				if (oStaff.BreakTime.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,oStaff.BreakTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@BreakTime",DbType.DateTime,DBNull.Value));
				if (oStaff.WorkList!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,oStaff.WorkList));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@WorkList",DbType.String,DBNull.Value));
				if (oStaff.IsScheduleWorkTime!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,oStaff.IsScheduleWorkTime));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsScheduleWorkTime",DbType.String,DBNull.Value));
				if (oStaff.IsCommissionService!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,oStaff.IsCommissionService));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsCommissionService",DbType.String,DBNull.Value));
				if (oStaff.IsServiceCard!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,oStaff.IsServiceCard));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@IsServiceCard",DbType.String,DBNull.Value));
				if (oStaff.AccountId.HasValue)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,oStaff.AccountId));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@AccountId",DbType.Int32,DBNull.Value));
				if (oStaff.Note!=null)
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,oStaff.Note));
				else
					oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@Note",DbType.String,DBNull.Value));
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,oStaff.ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveStaff(Staff oStaff)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [Staff] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,oStaff.ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
		public int RemoveStaff(string ID)
		{

			try
			{
				DbCommand oDbCommand = DbProviderHelper.CreateCommand("DELETE FROM [Staff] WHERE [ID]=@ID",CommandType.Text);
				oDbCommand.Parameters.Add(DbProviderHelper.CreateParameter("@ID",DbType.String,ID));
				return DbProviderHelper.ExecuteNonQuery(oDbCommand);
			}
			catch (Exception ex)
			{
				throw ex;
			}
		}
	}
}
